home *** CD-ROM | disk | FTP | other *** search
/ Personal Computer World 2009 February / PCWFEB09.iso / Software / Linux / SLAX 6.0.8 / slax-6.0.8.iso / slax / base / 006-devel.lzm / usr / include / kparts / event.h < prev    next >
Encoding:
C/C++ Source or Header  |  2005-10-10  |  3.7 KB  |  121 lines

  1. /* This file is part of the KDE project
  2.    Copyright (C) 1999 Simon Hausmann <hausmann@kde.org>
  3.              (C) 1999 David Faure <faure@kde.org>
  4.  
  5.    This library is free software; you can redistribute it and/or
  6.    modify it under the terms of the GNU Library General Public
  7.    License as published by the Free Software Foundation; either
  8.    version 2 of the License, or (at your option) any later version.
  9.  
  10.    This library is distributed in the hope that it will be useful,
  11.    but WITHOUT ANY WARRANTY; without even the implied warranty of
  12.    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  13.    Library General Public License for more details.
  14.  
  15.    You should have received a copy of the GNU Library General Public License
  16.    along with this library; see the file COPYING.LIB.  If not, write to
  17.    the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
  18.    Boston, MA 02110-1301, USA.
  19. */
  20. #ifndef __kparts_event_h__
  21. #define __kparts_event_h__
  22.  
  23. #include <qevent.h>
  24.  
  25. #include <kdelibs_export.h>
  26.  
  27. class QWidget;
  28.  
  29. namespace KParts
  30. {
  31. class Part;
  32.  
  33. /**
  34.  * Base class for all KParts events.
  35.  */
  36. class KPARTS_EXPORT Event : public QCustomEvent
  37. {
  38. public:
  39.   Event( const char *eventName );
  40.  
  41.   virtual const char *eventName() const;
  42.  
  43.   static bool test( const QEvent *event );
  44.   static bool test( const QEvent *event, const char *name );
  45. };
  46.  
  47. /**
  48.  * This event is sent to a Part when its GUI has been activated or deactivated.
  49.  * This is related to PartActivateEvent, but the difference is that
  50.  * GUIActivateEvent happens later (when the GUI is actually built),
  51.  * only for parts that have GUI elements, and only if using KParts::MainWindow.
  52.  * @see KParts::Part::guiActivateEvent()
  53.  */
  54. class KPARTS_EXPORT GUIActivateEvent : public Event
  55. {
  56. public:
  57.   GUIActivateEvent( bool activated ) : Event( s_strGUIActivateEvent ), m_bActivated( activated ) {}
  58.  
  59.   bool activated() const { return m_bActivated; }
  60.  
  61.   static bool test( const QEvent *event ) { return Event::test( event, s_strGUIActivateEvent ); }
  62.  
  63. private:
  64.   static const char *s_strGUIActivateEvent;
  65.   bool m_bActivated;
  66. };
  67.  
  68. /**
  69.  * This event is sent by the part manager when the active part changes.
  70.  * Each time the active part changes, it will send first a PartActivateEvent
  71.  * with activated=false, part=oldActivePart, widget=oldActiveWidget
  72.  * and then another PartActivateEvent
  73.  * with activated=true, part=newPart, widget=newWidget.
  74.  * @see KParts::Part::partActivateEvent
  75.  */
  76. class KPARTS_EXPORT PartActivateEvent : public Event
  77. {
  78. public:
  79.   PartActivateEvent( bool activated, Part *part, QWidget *widget ) : Event( s_strPartActivateEvent ), m_bActivated( activated ), m_part( part ), m_widget( widget ) {}
  80.  
  81.   bool activated() const { return m_bActivated; }
  82.  
  83.   Part *part() const { return m_part; }
  84.   QWidget *widget() const { return m_widget; }
  85.  
  86.   static bool test( const QEvent *event ) { return Event::test( event, s_strPartActivateEvent ); }
  87.  
  88. private:
  89.   static const char *s_strPartActivateEvent;
  90.   bool m_bActivated;
  91.   Part *m_part;
  92.   QWidget *m_widget;
  93. };
  94.  
  95. /**
  96.  * This event is sent when a part is selected or deselected.
  97.  * @see KParts::PartManager::setSelectionPolicy
  98.  */
  99. class KPARTS_EXPORT PartSelectEvent : public Event
  100. {
  101. public:
  102.   PartSelectEvent( bool selected, Part *part, QWidget *widget ) : Event( s_strPartSelectEvent ), m_bSelected( selected ), m_part( part ), m_widget( widget ) {}
  103.  
  104.   bool selected() const { return m_bSelected; }
  105.  
  106.   Part *part() const { return m_part; }
  107.   QWidget *widget() const { return m_widget; }
  108.  
  109.   static bool test( const QEvent *event ) { return Event::test( event, s_strPartSelectEvent ); }
  110.  
  111. private:
  112.   static const char *s_strPartSelectEvent;
  113.   bool m_bSelected;
  114.   Part *m_part;
  115.   QWidget *m_widget;
  116. };
  117.  
  118. } // namespace
  119.  
  120. #endif
  121.